﻿using System;
using Fluffy.Library.Mvvm;
using Fluffy.Library.Utils;
using MonoTorrent.Common;
using System.Windows.Media;

namespace Fluffy.Torrent
{
	public class TorrentFileViewModel : ViewModelBase
	{
		private readonly TorrentFile _torrent;

		public TorrentFileViewModel(TorrentFile torrent)
		{
			_torrent = torrent;
		}

		public ImageSource Icon
		{
			get { return UiUtils.GetFileIcon(_torrent.FullPath, false); }
		}

		public string Name
		{
			get { return System.IO.Path.GetFileName(_torrent.FullPath); }
		}

		public string Path
		{
			get { return _torrent.FullPath; }
		}

		public long Size
		{
			get { return _torrent.Length; }
		}

		public Priority Priority
		{
			get { return _torrent.Priority; }
			set
			{
				if (_torrent.Priority == value)
					return;

				_torrent.Priority = value;
				OnPropertyChanged("PriorityTitle");
			}
		}
		
		public string PriorityTitle
		{
			get { return Enum.GetName(typeof(Priority), _torrent.Priority); }
		}
		
		public string SizeTitle
		{
			get { return TitleUtils.GetTitleForSize(Size); }
		}
	}
}
